package com.melhoramigo.adapter;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;

import com.melhoramigo.CachorrosFragment;
import com.melhoramigo.R;
import com.melhoramigo.model.Cachorro;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.Toast;

public class ListaFotosCachorrosAdapter extends BaseAdapter{
	
	private ArrayList<Bitmap> bitmaps;
	private Activity activity;
	
	public ListaFotosCachorrosAdapter(ArrayList<Bitmap> bitmaps, Activity activity) {
		this.bitmaps = bitmaps;
		this.activity = activity;
	}

	@Override
	public int getCount() {
		return bitmaps.size();
	}

	@Override
	public Object getItem(int position) {
		return bitmaps.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
//		String url = urls.get(position);
		Bitmap bitmap = bitmaps.get(position);
		ImageView imagem = new ImageView(activity.getApplicationContext());

		if (bitmaps != null) {
			imagem.setImageBitmap(bitmap);
			imagem.setAdjustViewBounds(true);
		}
		else {
			imagem.setImageResource(R.drawable.bg5);
			imagem.setAdjustViewBounds(true);
		}
		return imagem;
	}

}
